/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.thinkinbunny.model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import org.thinkinbunny.data.DbConnect;
import org.thinkinbunny.data.DbHelper;

public class UserBeanDo {
	private Statement sm = null;
	private ResultSet rs = null;
	private Connection ct = null;
	private int pageCount = 0;
	private int rowCount = 0;
	private int pageSize = 3;







	public void close() { // 关闭各种打开的资源
		try {
			if (rs != null) {
				rs.close();
				rs = null;
			}
			if (sm != null) {
				sm.close();
				sm = null;
			}
			if (ct != null) {
				ct.close();
				ct = null;
			}
		} catch (Exception e) {
			e.printStackTrace();// 打印异常，以便修改
		}
	}



	public boolean checkUser(String u, String p) {
		boolean b = false;
		if (u != null && p != null) {
			try {
				ct = new DbConnect().getConn();// 获取ConnDB中的方法，操作数据库
				sm = ct.createStatement();
				rs = sm
						.executeQuery("select rootpassword from manger where rootuser='"
								+ u + "'");
				if (rs.next()) {
					System.out.print("u=" + u + "p=" + p);
					System.out.print(rs.getString(1));
					if (rs.getString(1).equals(p)) {

						b = true;
					}
				}

			} catch (Exception e) {
				e.printStackTrace();
			} finally { // 关闭各种打开的资源，释放内存
				this.close();
			}
		}

		return b;
	}



}